package com.google.firebase.quickstart.database.viewholder;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.firebase.quickstart.database.R;
import com.google.firebase.quickstart.database.common.data.model.User;
import com.squareup.picasso.Picasso;

public class UserViewHolder extends RecyclerView.ViewHolder {

    public TextView authorView;
    public ImageView post_author_photo;

    public UserViewHolder(View itemView) {
        super(itemView);
        authorView = itemView.findViewById(R.id.post_author);
        post_author_photo = itemView.findViewById(R.id.post_author_photo);
    }

    public void bindToPost(User user) {
        if (user != null) {
            authorView.setText(user.getName());
            Picasso.with(post_author_photo.getContext()).load(user.getAvatar()).into(post_author_photo);
        }
    }
}
